package com.city.controller.command;

import com.city.config.BaiduMap;
import com.city.domain.city.CityEvent;
import com.city.domain.city.CityTown;
import com.city.domain.pub.PubUser;
import com.city.domain.report.CtReport;
import com.city.domain.supervise.PubKeyPerson;
import com.city.format.CtReportFormat;
import com.city.helper.FormatHelper;
import com.city.repository.pub.PubKeyPersonRepository;
import com.city.service.city.CityTownService;
import com.city.service.city.impl.CityEventServiceImpl;
import com.city.service.city.impl.CityTownServiceImpl;
import com.city.service.report.ReportService;
import com.city.service.supervise.PubKeyPersonService;
import org.hibernate.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @deprecation 综合指挥
 * @email leichuqiao@126.com
 * @author 雷楚桥
 * @date 2018-07-06 20:29
 */
@Controller
@RequestMapping("/command")
public class CommandController {
    @Autowired
    private ReportService reportService;
    @Autowired
    private FormatHelper formatHelper;
    @Autowired
    private PubKeyPersonRepository pubKeyPersonRepository;
    @Autowired
    private CityTownService cityTownService;

    /**
     * @deprecation 主页
     * @author 雷楚桥
     * @date 2018-07-06 20:31
     */
    @RequestMapping("/index")
    public String index(){
        return "/command/index";
    }

    /**
     * @deprecation 地图信息联动
     * @author 雷楚桥
     * @date 2018-07-06 21:48
     */
    @RequestMapping("/map")
    public String map(Map<String,Object> map){
        map.put("AK","kwGnEQsGAgvGoTxHtGBDgG764aSDiwfD");
        return "/command/map";
    }

    /**
     * @Author 何平
     * @Description //TODO detail返回地图联动详细数据
     * @Date 16:43 2018/8/2
     * @Param [map, id]
     * @return java.lang.String
     **/
    @RequestMapping("/detail")
    public String detail(Map<String,Object> map, @Param("id") Integer id){
        CtReport ctReport = reportService.findReportById(id);
        map.put("id", id);
        map.put("AK","kwGnEQsGAgvGoTxHtGBDgG764aSDiwfD");
        map.put("reportFormat", formatHelper.ctReportFormat(ctReport));
        return "/command/detail";
    }

    /**
     * @Author 何平
     * @Description //TODO evaluate 综合评价查询
     * @Date 18:33 2018/8/3
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/evaluate")
    public String evaluate(){
        return "/command/evaluate";
    }

    /**
     * @Author 何平
     * @Description //TODO 综合评价详情
     * @Date 10:13 2018/8/18
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/evaluate_detail")
    public String evaluate_detail(Map<String,Object> map, @Param("id") Integer id){
        //详情
        CtReport ctReport = reportService.findReportById(id);
        map.put("reportFormat", formatHelper.ctReportFormat(ctReport));
        map.put("AK",BaiduMap.BAIDU_AK);
        return "/command/evaluate_detail";
    }

    /**
     * @Author 何平
     * @Description //TODO grid_scatter 网格员分布
     * @Date 9:06 2018/8/4
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/grid_scatter")
    public String grid_scatter(Map<String,Object> map){
        List<CityTown> list = cityTownService.findName("1");
        map.put("AK",BaiduMap.BAIDU_AK);
        map.put("list",list);
        return "/command/grid_scatter";
    }

    /**
     * @Author 何平
     * @Description //TODO 网格员分布详情
     * @Date 10:06 2018/9/21
     * @Param [map]
     * @return java.lang.String
     **/
    @RequestMapping("/scatter_detail")
    public String scatter_detail(Map<String,Object> map, @Param("id") Integer id){
        map.put("id",id);
     return "/command/scatter_detail";
    }
    
    /**
     * @Author 何平
     * @Description //TODO trajectory 网格员轨迹
     * @Date 9:52 2018/8/5
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/trajectory")
    public String trajectory(Map<String,Object> map){
        List<PubKeyPerson> list = pubKeyPersonRepository.findAll();
        map.put("AK",BaiduMap.BAIDU_AK);
        map.put("list",list);
        return "/command/trajectory";
    }

    /*
     * @Author 何平
     * @Description //TODO data_show 数据综合展示
     * @Date 9:20 2018/8/6
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/data_show")
    public String data_show(Map<String,Object> map){
        map.put("AK",BaiduMap.BAIDU_AK);
        return "/command/data_show";
    }

    /**
     * @Author: 李顺时
     * @Description: 专业部门总体综合评价表
     * @Date: 15:05 2018/9/12
     */
    @RequestMapping("/department_comp")
    public String department_comp(Map<String,Object> map){
        map.put("AK",BaiduMap.BAIDU_AK);
        return "/command/department_comp";
    }

    @RequestMapping("/department_details")
    public String department_details(Map<String,Object> map){
        map.put("AK",BaiduMap.BAIDU_AK);
        return "/command/department_details";
    }

    
    /*
     * @Author 何平
     * @Description //TODO notice 逆向提醒报告
     * @Date 21:09 2018/9/28
     * @Param []
     * @return java.lang.String
     **/
    @RequestMapping("/notice")
    public String notice(){
        return "/command/notice";
    }
}
